package route

import (
	"EinoService/middleware"
	"EinoService/utils"
	"github.com/gin-gonic/gin"
)

func InitRoute(config *utils.Config) *gin.Engine {
	gin.SetMode(config.App.Mode)
	route := gin.New()
	route.MaxMultipartMemory = int64(config.App.MaxUploadSize) << 20
	route.Use(gin.Recovery())
	route.Use(middleware.LoggerToFile(config))
	// router set
	Config(route)

	route.NoRoute(func(context *gin.Context) {
		context.JSON(200, map[string]any{
			"code": 500,
			"msg":  "接口不存在",
			"data": make(map[string]any),
		})
	})
	return route
}
